<?php
session_start();
include("../include/config.inc.php");
include("../include/version.inc.php");
include("../include/tables.inc.php");
include("../include/funktion.inc.php");

$fehler = "";
$was = $_GET['was'];

if($was == "logout")
   {
   session_destroy();
   $fehler = "Logout erfolgreich";
   }

if($was == "login")
   {
   $username = $_POST['username'];
   $pw = md5($_POST['pw']);


   $abfrage = "SELECT `id`,`username`,`pw`,`rights` FROM `$userdb` WHERE `username` = '$username' AND `pw` = '$pw'";
   $ergebnis = mysql_query($abfrage);

   if(mysql_num_rows($ergebnis))
      {
      $row = mysql_fetch_object($ergebnis);
      $_SESSION['userid'] = $row->id;
      $_SESSION['username'] = $row->username;
      $_SESSION['ses_rights'] = $row->rights;
      }
   else
      {
      $fehler = "Benutzername und/oder Passwort falsch";
      }
   }

if(isset($_SESSION['userid']))
   {
   weiterleitung("uebersicht.php");
   }

?>
<?php header("P3P: CP=\"CAO PSA OUR\"");  ?>

<html>
<head>
<title>Clanletter - Admin Bereich</title>
<meta name="author" content="Andavos">
<style type="text/css">
<!--
a:hover { text-decoration:none; }

BODY {

     SCROLLBAR-FACE-COLOR: #4F5271;
     SCROLLBAR-HIGHLIGHT-COLOR: #243D62;
    SCROLLBAR-SHADOW-COLOR: rgb(32,32,32);
    SCROLLBAR-ARROW-COLOR: #ffffff;

}

-->
</style>

</head>
<body text="#000000" bgcolor="#D0D0D0" link="#000060" alink="#000060" vlink="#000060">

<form action="?was=login" method="post">
<table cellspacing="1" cellpadding="5" border="0" bgcolor="#000000" width="550" align="center">
<tr bgcolor="#314477">
<th><font color="#ffffff" size="+1">Login</font></th>
</tr>
<tr bgcolor="#ffffff">
<td>

<center><font color="#DE0000"><?php echo $fehler; ?></font></center>

Benutzername:<br>
<input type="Text" name="username" value="" size="20" maxlength="60"><br><br>

Passwort:<br>
<input type="Password" name="pw" value="" size="20" maxlength="60"><br>
&nbsp;&nbsp;<input type="Submit" name="" value="Login">

</td>
</tr>

</table>
</form>

</body>
</html>
